this._gjs_closure = new St.Label();
this.actor.add(this._gjs_closure);
+ this._last_gc_seconds_ago = new St.Label();
+ this.actor.add(this._last_gc_seconds_ago);
+
this._gcbutton = new St.Button({ label: 'Full GC',
style_class: 'lg-obj-inspector-button' });
this._gcbutton.connect('clicked', Lang.bind(this, function () { global.gc(); this._renderText(); }));
this._gjs_gobject.text = 'gjs_gobject: ' + memInfo.gjs_gobject;
this._gjs_function.text = 'gjs_function: ' + memInfo.gjs_function;
this._gjs_closure.text = 'gjs_closure: ' + memInfo.gjs_closure;
+ this._last_gc_seconds_ago.text = 'last_gc_seconds_ago: ' + memInfo.last_gc_seconds_ago;
}
};
static ShellGlobal *the_object = NULL;
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
+static void shell_global_on_gc (GjsContext *context,
+ ShellGlobal *global);
struct _ShellGlobal {
GObject parent;
ca_context *sound_context;
guint32 xdnd_timestamp;
+
+ gint64 last_gc_end_time;
};
enum {
global->js_context = g_object_new (GJS_TYPE_CONTEXT,
"search-path", search_path,
"js-version", "1.8",
+ "gc-notifications", TRUE,
NULL);
+ g_signal_connect (global->js_context, "gc", G_CALLBACK (shell_global_on_gc), global);
+
g_strfreev (search_path);
}
gjs_context_maybe_gc (global->js_context);
}
+static void
+shell_global_on_gc (GjsContext *context,
+ ShellGlobal *global)
+{
+ global->last_gc_end_time = g_get_monotonic_time ();
+}
+
/**
* shell_global_get_memory_info:
* @global:
ShellMemoryInfo *meminfo)
{
JSContext *context;
+ gint64 now;
memset (meminfo, 0, sizeof (meminfo));
#ifdef HAVE_MALLINFO
meminfo->gjs_gobject = (unsigned int) gjs_counter_object.value;
meminfo->gjs_function = (unsigned int) gjs_counter_function.value;
meminfo->gjs_closure = (unsigned int) gjs_counter_closure.value;
+
+ now = g_get_monotonic_time ();
+
+ meminfo->last_gc_seconds_ago = (now - global->last_gc_end_time) / G_TIME_SPAN_SECOND;
}